/**
 * Created by 功振 on 2016/4/20.
 */
angular.module('NatureCloud').controller('InstanceShellController', ["$scope", "$stateParams", "$sce", "$cookies", "VALUE", function ($scope, $stateParams, $sce, $cookies, VALUE) {



    $scope.$on('getShellEvt',function(event,item){

        var instanceName = item.metadata.name;
        var ns =  $cookies.get("username");
        var svc = $scope.svc; // Inherited from ServiceDetailController
        var shell = "/bin/bash";
        if (svc.dbJson.node.shell)
            shell = svc.dbJson.node.shell;
        var webShellHostPort = VALUE.WEB_SHELL_HOSTPORT;
        var clusterId = svc.dbJson.node.clusterId;
        if (clusterId && clusterId !== "default") {
            //webShellHostPort = clusterId + "webshell.tunnel.naturecloud.io:8080";
            webShellHostPort = clusterId + "webshell."+VALUE.TUNNEL_DOMAIN;
        }
        $scope.url = $sce.trustAsResourceUrl('http://' + webShellHostPort + '/login?rid=' + instanceName + "&ns=" + ns + "&command=" + shell);
    });
}]);
